home *** CD-ROM | disk | FTP | other *** search
- Path: s02.pavilion.co.uk!usenet
- From: AJRobb@pavilion.co.uk (Andy J Robb)
- Newsgroups: comp.lang.c
- Subject: Re: void pointers
- Date: Sat, 13 Jan 1996 15:32:15 GMT
- Organization: Pavilion Internet plc
- Message-ID: <4d8j83$n3@s02.pavilion.co.uk>
- References: <1996Jan12.133322.1@ccc.govt.nz>
- NNTP-Posting-Host: poolb34.pavilion.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- mcauslanb@ccc.govt.nz wrote:
-
- >I am writing a C program for an application that has a development language
- >based on ANSI C.
-
- >A function that I need to call is defined:
- > void getFence (void **clipPP);
-
- > where "clipPP" is returned by the function.
-
- >1) How do I declare and pass clipPP?
-
- YourType *clipP; /* set up an unitialized pointer */
- getFence(&clipP); /* initialize it in the functions */
-
- >2) What is actually going on?
-
- The (void*) type is a dirty catch-all pointer. It can point to
- anything but you must cast it or assign it to something else before
- you use it.
-
- In my example, I have shown that I have a pointer to a type
- (YourType). This allows the returned pointer to be used without
- casting. I then passed the address OF this pointer (rather than the
- address held by the pointer) to the function, getFence(). The
- prototype declaration of getFence() will cause an implicit cast to
- (void**) in the call. The function, getFence(), then does its
- business and returns the address of the result in the pointer, clipP.
- It can do this because you gave it the address of clipP.
-
- Regards,
-
- -----BEGIN PGP PUBLIC KEY BLOCK-----
- Version: 2.6.2i
-
- mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
- MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
- B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
- tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
- IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
- =/wVD
- -----END PGP PUBLIC KEY BLOCK-----
-
-